﻿using System;
using MetroGA.Win8.Lib;
using Windows.ApplicationModel.Activation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace MetroGA.Samples.Windows8
{
	sealed partial class App
	{
		public App()
		{
			InitializeComponent();
		}

		protected override void OnLaunched(LaunchActivatedEventArgs args)
		{
			MetroAnalytics.Initialize("UA-35058453-2", applicationVersion: DateTime.Now.ToString("1.MMdd.HHmm"));
			
			UnhandledException += (sender, e) => MetroAnalytics.Current.TrackException(e.Exception);

			var rootFrame = Window.Current.Content as Frame;
			if (rootFrame == null)
			{
				rootFrame = new Frame();
				rootFrame.Navigated += (sender, e) => MetroAnalytics.Current.TrackView(e.SourcePageType);
				Window.Current.Content = rootFrame;
			}

			Window.Current.Activate();
			rootFrame.Navigate(typeof (MainPage));
		}
	}
}
